package com.yunhai.device.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yunhai.common.dto.PaginationVo;
import com.yunhai.common.dto.Ret;
import com.yunhai.device.service.OrrMaterialInterruptSummaryService;
import com.yunhai.model.entity.orr.OrrMaterialInterruptSummaryEntity;
import com.yunhai.model.vo.orr.OrrMaterialInterruptSummaryQuery;
import com.yunhai.model.vo.orr.OrrMaterialInterruptSummaryVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/orrMaterialInterruptSummary")
public class OrrMaterialInterruptSummaryController {

	@Resource
	private OrrMaterialInterruptSummaryService orrMaterialInterruptSummaryService;


	/**
	 * 获取 OrrMaterialInterruptSummary 分页列表
	 */
	@GetMapping("/pagination")
	public Ret getOrrMaterialInterruptSummaryPagination(PaginationVo paginationVo, OrrMaterialInterruptSummaryQuery orrMaterialInterruptSummaryQuery ) throws Exception {
		IPage page = orrMaterialInterruptSummaryService.getOrrMaterialInterruptSummaryPagination(paginationVo, orrMaterialInterruptSummaryQuery );
		return Ret.toPage(page);
	}


	/**
	 * 获取 OrrMaterialInterruptSummary 所有数据
	 */
	@GetMapping("/allList")
	public Ret getOrrMaterialInterruptSummaryAllList( OrrMaterialInterruptSummaryQuery orrMaterialInterruptSummaryQuery ) throws Exception {
		List<OrrMaterialInterruptSummaryEntity> list = orrMaterialInterruptSummaryService.getOrrMaterialInterruptSummaryAllList( orrMaterialInterruptSummaryQuery );
		return Ret.ok(list);
	}


	/**
	 * 获取 OrrMaterialInterruptSummary 详情
	 */
	@GetMapping("/{id}")
	public Ret getOrrMaterialInterruptSummaryDetailById(@PathVariable Long id) throws Exception {

	    OrrMaterialInterruptSummaryEntity orrMaterialInterruptSummaryEntity = orrMaterialInterruptSummaryService.getOrrMaterialInterruptSummaryDetail(id);
		return Ret.ok(orrMaterialInterruptSummaryEntity);
	}


	/**
	 * 新增 OrrMaterialInterruptSummary
	 * */
	@PostMapping("")
	public Ret addOrrMaterialInterruptSummary(@RequestBody OrrMaterialInterruptSummaryVo orrMaterialInterruptSummaryVo) throws Exception {

		orrMaterialInterruptSummaryService.addOrrMaterialInterruptSummary(orrMaterialInterruptSummaryVo);
		return Ret.ok();
	}


	/**
	 * 更新 OrrMaterialInterruptSummary
	 * */
	@PutMapping("")
	public Ret updateOrrMaterialInterruptSummary(@RequestBody OrrMaterialInterruptSummaryVo orrMaterialInterruptSummaryVo) throws Exception {

		orrMaterialInterruptSummaryService.updateOrrMaterialInterruptSummary(orrMaterialInterruptSummaryVo);
		return Ret.ok();
	}


	/**
	 * 删除 OrrMaterialInterruptSummary
	 * */
	@PostMapping("/batchRemove")
	public Ret batchRemoveOrrMaterialInterruptSummary( @RequestBody List<Long> ids ) throws Exception {

	    orrMaterialInterruptSummaryService.batchRemoveOrrMaterialInterruptSummary(ids);
		return Ret.ok();
	}
}
